package manytoone.filter;

import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;

import java.io.IOException;

/**
 * @Author 宋伟宁
 * @Date 2023/9/6
 * @Version 1.0
 **/
//@WebFilter("/*")
public class EncodingFilter implements Filter {

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
           System.out.println("设置中文编码的过滤器");
           servletResponse.setContentType("text/html;charset=utf-8");
           servletRequest.setCharacterEncoding("utf-8");
           filterChain.doFilter(servletRequest,servletResponse);

    }
}
